package com.santiao.publics.base

import android.app.Activity
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment

open class BaseFragment: Fragment() {
    var mActivity: Activity? = null
    interface OnFragmentInitializedListener {
        fun onFragmentInitialized()
    }

    private var mListener: OnFragmentInitializedListener? = null
    fun setOnFragmentInitializedListener(listener: OnFragmentInitializedListener) {
        this.mListener = listener
    }
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
    }

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        return super.onCreateView(inflater, container, savedInstanceState)
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
    }

    override fun onActivityCreated(savedInstanceState: Bundle?) {
        super.onActivityCreated(savedInstanceState)
        mActivity = activity
        if (mListener != null) {
            mListener?.onFragmentInitialized()
        }
    }
}